﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Collections;

namespace WebApplication1
{
    public partial class _Default : Page
    {



        #region 初始化
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        #endregion

        #region 登录
        protected void Button3_Click(object sender, EventArgs e)
        {
            var name = TextBox1.Text.Trim();
            var sql = string.Format("select * from Girl where name='{0}'", name);
            var conet = DbHelp.DataTable(sql);
            if (conet.Rows.Count > 0)
            {
                //Response.Redirect("Login.aspx");
                Response.Write("<script>window.location.href='login.aspx'</script>");
            }
            else
            {
                Label3.Text = "姓名错误";
            }
        }
        #endregion

        #region 注册
        protected void Button4_Click(object sender, EventArgs e)
        {
            Response.Redirect("Register.aspx");
        }
        #endregion

        #region 登录控件
        protected void login_Authenticate(object sender, AuthenticateEventArgs e)
        {
            var name = login.UserName.Trim();
            var pwd = login.Password.Trim();
            var sql = string.Format("select * from X where UserName='{0}' and Password='{1}'", name, pwd);
            var a = DbHelp.DataTable(sql);
            if (a.Rows.Count == 1)
            {
                var b = (bool)a.Rows[4].ItemArray[1];
                var c = (bool)a.Rows[4].ItemArray[2];
                if (b)
                {
                    //已删除
                }
                else if (c)
                {
                    //登录成功
                }
                else
                {
                    //已禁用
                }
            }
        }
        #endregion

    }
}